import random

from matplotlib import pyplot as plt


def matTest(num=10):
    x = range(1, num + 1)
    y = []
    for i in x:
        y.append(random.randrange(1, 50))
    #  设置图片大小
    # plt.figure(figsize=(16, 9), dpi=200)

    # 绘图
    plt.plot(x, y)

    # 设置x轴的刻度
    # plt.xticks(x)
    _x = x
    _xStick_labels = ["a{}".format(i) for i in _x]

    # x轴刻度尺设置  切片[::step]取步长
    plt.xticks(_x[::2], _xStick_labels[::2], rotation=-45)  # rotation旋转r45

    # 设置y轴的刻度
    plt.yticks(range(min(y), max(y), 2))

    # 网格线
    plt.grid()

    # 添加描述信息
    plt.xlabel("here input x-axis>>")
    plt.ylabel("here input y-axis>>")
    plt.title("here input title>>")
    # plt.xlabel("x轴")
    # plt.ylabel("y轴 ", rotation=0)

    # 显示出图Module
    plt.show()

    # 保存
    # path = "D:/XCZ/Pictures/Pycharm_Matplotlib/mat_{:0>3d}.png".format(y[1])
    # plt.savefig(path)
    # print(y[1])


# matTest(int(input("num=")))
matTest(10)
